package com.zpark.controller;

import com.zpark.feign.IFeignServerUserControllerFeign;
import com.zpark.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @PackageName: com.zpark.controller
 * @ClassName: ConsumerController
 * @Description:
 * @author: RZS
 * @date: 2024/4/17  12:08
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    // 自动注入Feign客户端
    @Autowired
    private IFeignServerUserControllerFeign serverUserControllerFeign;


    @GetMapping("/all")
    public List<User> getAllUser(){
        return serverUserControllerFeign.getAll();
    }

    @GetMapping("/get_id/{id}")
    public User getById(@PathVariable Integer id){

        return serverUserControllerFeign.getId(id);
    };

    @PostMapping("/update")
    public void updateUser(@RequestBody User user){
        serverUserControllerFeign.update(user);
    }

    @PostMapping("/insert")
    public void insertUser(@RequestBody User user){
        serverUserControllerFeign.insert(user);
    }

    @GetMapping("/del/{id}")
    public void deleteById(@PathVariable Integer id){
        serverUserControllerFeign.delete(id);
    }
}
